/**
 * @param {number[]} nums
 * @return {number}
 */
var mostFrequentEven = function (nums) {
  let map =new Map()
  for(const num of nums){
    if(num%2==0){
      map.set(num,map.get(num)+1 || 1)
    }
  }
  let maxkey,maxvalue=0
  for(const [key,value] of map.entries()){
    if(value>maxvalue){
      maxkey=key
      maxvalue=value
    }
  }

  return maxkey

};

mostFrequentEven(
  [0,1,2,2,4,4,1])